#ifndef _SWI2C_H_
#define _SWI2C_H_

#include <stdint.h>

#define SWI2C_SDA_OUTPUT 0
#define SWI2C_SDA_INPUT  1

typedef struct swi2c {
	struct {
		struct {
			int speed; /* 100000 or 400000 */
		} fix;
		struct {
			int res;
		} var;
	} cfg;
	struct {
		void (*usleep)(int us);
		void (*scl_set_val)(int val);
		void (*sda_set_dir)(int dir);
		void (*sda_set_val)(int val);
		int (*sda_get_val)();
	} ops;
} swi2c_t;

void swi2c_start(swi2c_t* i2c);
void swi2c_stop(swi2c_t* i2c);
void swi2c_send_byte(swi2c_t* i2c, uint8_t byte);
uint8_t swi2c_receive_byte(swi2c_t* i2c);
int swi2c_wait_response(swi2c_t* i2c);
void swi2c_response(swi2c_t* i2c);
void swi2c_no_response(swi2c_t* i2c);

#endif
